< previous page page_137 next page >

Page 137
      If nullpos = 0 Then
         ' This should never, ever happen
         ' Just return what we have up to now
         GetFileArray = results()
         Exit Function
      End If
      If nullpos = curpos Then
         'It's the second null, we're done
         GetFileArray = results()
         Exit Function
      End If
      itemcount = itemcount + 1
      ReDim Preserve results(itemcount)
      results(itemcount) = Mid$(NullsString, curpos, nullpos - curpos)
      curpos = nullpos + 1
   Loop While True
End Function
Why does this function provide for a user-defined separator character? Because many programs allow you to enter a list of files separated by spaces in a text box. The same function that parses strings separated by nulls can easily handle strings separated by spaces as well.
The FileOp1 Sample Program
The program contains a single list box that has its OLEDropMode property set to 1 Manual. The OLE events for the list box are defined so that files dragged from Windows Explorer onto the list box are detected using the following code:
' This event is raised when files are dropped
Private Sub lstFiles_OLEDragDrop(Data As DataObject, Effect As Long, Button As _
Integer, Shift As Integer, x As Single, Y As Single)
   Dim count&, idx&

If (Effect And vbDropEffectCopy) <> 0 Then
      Effect = vbDropEffectCopy

      count = Data.files.count

      ReDim FileList(count)
      lstFiles.Clear
      ' Load the list of files

 
< previous page page_137 next page >